{{extend 'layout.html'}}
{{block sectionclass}}ticket{{end}}
<!-- begin "ticket" block -->
<h2>{{=T('Error ticket')}} for "{{=app}}"</h2>
<h3>{{=T('Ticket ID')}}</h3>
<p>{{=ticket}}</p>
{{if output:}}<h4>{{=output}}</h4>{{pass}}
<h3>{{=T('Version')}}</h3>
<table class="versions">
  <tbody>
    <tr>
      <th>web2py&trade;</th>
      <td>Version {{=myversion}}</td>
    </tr>
    {{if snapshot:}}
    <tr>
      <th>Python</th>
      <td>{{=snapshot.get('pyver','')}}</td>
	</tr>
    {{pass}}
  </tbody>
</table>
{{if traceback or code or layer:}}
<h3>{{=T('Traceback')}}</h3>
<div class="inspect resp1">{{=traceback}}</div>
{{if snapshot:}}
{{try:}}
<!-- ERROR SNAPSHOT -->
<h3>{{=T('Error snapshot')}}
  <a href="#" rel="tooltip" data-placement="right" data-original-title="{{=T('Detailed traceback description')}}">
    {{=helpicon()}}
    <span>{{=T("Detailed traceback description")}}</span>
  </a>
</h3>
<!-- SNAPSHOT LIST -->
<div id="snapshot">
  <!-- Exception details -->
  <p class="exception_object inspect">
    <code>{{=snapshot['etype']}}({{=snapshot['evalue']}})</code>
  </p>
  <p class="controls">
    <a class="button btn" onclick="collapse('exception_inner');"><span>{{=T('inspect attributes')}}</span></a>
  </p>
  <div id="exception_inner" class="hide">
    <div class="inspect">
      <h4>{{=T("Exception instance attributes")}}</h4>
      <table>
	<tbody>
	  {{for k,v in snapshot['exception'].items():}}
	  <tr>
	    <th>{{=k}}</th>
	    <td>{{=v}}</td>
	  </tr>
	  {{pass}}
	</tbody>
      </table>
    </div>
  </div>
</div>
<!-- FRAMES -->
<div id="frames">
  <h4>{{=T('Frames')}}</h4>
  <ul class="unstyled">
    {{for i, frame in enumerate(snapshot['frames']):}}
    <li>
      {{is_hidden = (i != len(snapshot['frames'])-1 and 'hide' or 'inspect')}}
      <div class="framefile inspect controls">
	<p>
	  <strong>File {{="%s in %s at line %s" % (frame['file'], frame['func'], frame['lnum'])}}</strong>
	  <a class="button tbbutton btn" onclick="collapse('{{='%s_code_inner' % i}}');"><span>{{=T("code")}}</span></a>
	  <a class="button tbbutton btn" onclick="collapse('{{='%s_args_inner' % i}}');"><span>{{=T("arguments")}}</span></a>
	  <a class="button tbbutton btn" onclick="collapse('{{='%s_vars_inner' % i}}');"><span>{{=T("variables")}}</span></a>
	</p>
	<div id="{{='%s_args_inner' % i}}" class="{{=is_hidden}}" style="width:100%;overflow:auto">
	  <h5>Function argument list</h5>
	  <p>{{=frame['call']}}</p>
	</div>
	<div id="{{='%s_code_inner' % i}}" class="{{=is_hidden}}" style="width:100%;overflow:auto">
	  <h5>Code listing</h5>
	  {{if frame['lines']:}}
	  <pre>{{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda x: x[0])]),
	    language='python', link=None, counter=min(frame['lines'].keys()), highlight_line=frame['lnum'])}}</pre>
	  {{pass}}
	</div>
	<div id="{{='%s_vars_inner' % i}}" class="{{=is_hidden}}" style="width:100%;overflow:auto">
	  <h5>Variables</h5>
	  <table>
	    <tbody>
	      {{for k,v in frame['dump'].items():}}
	      <tr>
		<th>{{=k}}</th>
		<td>{{=v}}</td>
	      </tr>
	      {{pass}}
	    </tbody>
	  </table>
	</div>
      </div>
    </li>
    {{pass}}
  </ul>
</div>
<!-- VIEW ENVIRONMENT -->
<div class="viewenv">
  <h4><span>Context</span></h4>
  <p class="controls">
    <a class="button btn" onclick="jQuery('#locals').slideToggle()"><span>{{=T('locals')}}</span></a>
    <a class="button btn" onclick="jQuery('#request').slideToggle()"><span>{{=T('request')}}</span></a>
    <a class="button btn" onclick="jQuery('#session').slideToggle()"><span>{{=T('session')}}</span></a>
    <a class="button btn" onclick="jQuery('#response').slideToggle()"><span>{{=T('response')}}</span></a>
  </p>
  <div class="hide inspect resp1" id="locals"><h4>locals</h4>
    {{=BEAUTIFY(snapshot.get('locals','no locals available in snapshot'))}}
  </div>
  <div class="hide inspect" id="request"><h4>request</h4>
    {{=XML(snapshot.get('request','no request available in snapshot'))}}
  </div>
  <div class="hide inspect" id="session"><h4>session</h4>
    {{=XML(snapshot.get('session','no session available in snapshot'))}}
  </div>
  <div class="hide inspect" id="response"><h4>response</h4>
    {{=XML(snapshot.get('response','no response available in snapshot'))}}
  </div>
</div>
{{except Exception, e:}}
<!-- this should not happen, just in case... (cannot output normal hmtl as we don't know current open tags) -->
{{import traceback;tb=traceback.format_exc().replace("\n","\\n") }}
<script language='javascript'>alert("Exception during snapshot rendering: {{=tb}} ");</script>
{{pass}}
{{pass}}

<div class="errorsource">
  <h3>In file: {{=layer}}</h3>
  {{=CODE(code.replace('\r',''),language='python',link='/examples/global/vars/')}}
</div>
{{else:}}
<h3>{{=T('Ticket Missing')}}</h3>
{{pass}}
<!-- end "ticket" block -->
